#include "um.h"
#include "memlayout.h"


		.section .__syscall_stub, "ax"
		.globl stub_start
		
		.globl stub_entry
stub_entry:
		/* ummap anything above UM_SHARED_MEM_END */
		movl	$(__NR_munmap), %eax
		movl	$(UM_SHARED_MEM_END), %ebx
		movl	$(UM_SPACE_TOP - UM_SHARED_MEM_END), %ecx
		int 	$0x80

		/* map stack */
		movl	$(__NR_mmap), %eax
		movl	$(UM_STUB_DATA), %ebx
		int 	$0x80
		movl	$(UM_SPACE_TOP), %esp

		/* Calculate the entry of 'stub_start' and call it */
		lea		__syscall_stub_start, %eax
		lea		stub_start, %ebx
		subl	%eax, %ebx
		lea		stub_start, %eax
		addl	$(UM_STUB_CODE), %ebx

		call 	*%ebx